/*********************\
* Author:Dzlua
* QQ:505544956
* Time:2017/04/15
\**********************/
#include "LuaListTextExtElement.h"

#define CObjPtr ((CListTextExtElementUI*)m_cobj)

namespace DuiLib {

int LuaListTextExtElement::GetText(LuaState *L)
{
    LuaStack args(L);
    int iIndex = LuaHelperNS::GetInt(args[2]);
    SDTString str = CObjPtr->GetText(iIndex);
    LuaHelperNS::PushTString(L, str);
    return 1;
}

int LuaListTextExtElement::SetText(LuaState *L)
{
    LuaStack args(L);
    int iIndex = LuaHelperNS::GetInt(args[2]);
    SDTString str = LuaHelperNS::GetTString(args[3]);
    CObjPtr->SetText(iIndex, str.c_str());
    return 0;
}

int LuaListTextExtElement::GetLinkContent(LuaState *L)
{
    LuaStack args(L);
    int iIndex = LuaHelperNS::GetInt(args[2]);
    SDTString str = CObjPtr->GetLinkContent(iIndex)->GetData();
    LuaHelperNS::PushTString(L, str);
    return 1;
}

int LuaListTextExtElement::EstimateSize(LuaState *L)
{
    LuaStack args(L);
    SIZE szAvailable = LuaHelperNS::GetSize(args[2]);
    SIZE sz = CObjPtr->EstimateSize(szAvailable);
    LuaHelperNS::PushSize(L, sz);
    return 1;
}

SDLUA_BEGIN_REGISTER(LuaListTextExtElement, ListTextExtElement, ListLabelElement)
    SDLUA_REGISTER_FUN_LUA(LuaListTextExtElement, GetText, GetText)
    SDLUA_REGISTER_FUN_LUA(LuaListTextExtElement, SetText, SetText)
    SDLUA_REGISTER_FUN_LUA(LuaListTextExtElement, GetLinkContent, GetLinkContent)
    SDLUA_REGISTER_FUN_LUA(LuaListTextExtElement, EstimateSize, EstimateSize)

SDLUA_END_REGISTER

SDLUA_BEGIN_UNREGISTER(LuaListTextExtElement, ListTextExtElement)
SDLUA_END_UNREGISTER(ListTextExtElement)

}

#undef CObjPtr